package com.git_demo.service.impl;

import com.git_demo.bean.Student;
import com.git_demo.mapper.StudentMapper;
import com.git_demo.service.StudentService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;


/**
 * @author 金振宇
 * @describe
 */
@Service
@Component
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper studentMapper;

    @Override
    public List<Student> selectAllStudent() throws Exception{
        return studentMapper.selectAllStudent();
    }

    @Override
    public void deleteStuById(Integer stuId) throws Exception {
        studentMapper.deleteByPrimaryKey(stuId);
    }

    @Override
    public void updateStu(Student student) throws Exception {
        studentMapper.updateByPrimaryKeySelective(student);
    }


    @Override
    public void addStu(Student student)throws Exception {
        studentMapper.insertSelective(student);
    }

    @Override
    public Student findStudentById(Integer stuId) throws Exception {
        Student student = studentMapper.selectByPrimaryKey(stuId);
        return student;
    }
}
